package salb1;

import java.util.LinkedList;
import java.util.List;

import common.BasicAgent;

public class Helper {

    public static List<List<Integer>> deepCopyGroups(List<List<Integer>> subList) {
        
        List<List<Integer>> result = new LinkedList<List<Integer>>();
        for (List<Integer> group : subList) {
            result.add(new LinkedList<Integer>(group));
        }
        return result;
    }
    
    public static <T extends BasicAgent<Salb1Genotype>> String agentsToString(List<T> agents) {
        
        StringBuffer sb = new StringBuffer();
        for (T agent : agents) {
            sb.append(agentToString(agent)+"\n");
        }
        return sb.toString();

    }
    
    public static <T extends BasicAgent<Salb1Genotype>> String agentToString(T agent) {

        StringBuffer sb = new StringBuffer();
        List<Double> values = agent.getValues();

        sb.append(values.get(0)+","+values.get(1)+" ");
        sb.append(agent.getGenotype());

        return sb.toString();
    }

}
